from cart import models
from course.models import CourseModel
from rest_framework import serializers


class CartSerializer(serializers.ModelSerializer):
    courselist = serializers.SerializerMethodField()

    def get_courselist(self, obj):
       coursedata=CourseModel.objects.filter(id=obj.course.id).first()

       return{"name": coursedata.name,"img":str(coursedata.image),"price":coursedata.price,"courseid":coursedata.id}
    class Meta:
        model = models.CartModel
        fields = '__all__'